function Timer(timeout){
    let interval = null;
    let data = {};
    let _that = this;
    let init = function(intervalObj){
        return {};
    }
    let event = function(data, intervalObj){}
    let stop = function(){
        console.log("stop");
        if (interval !== null){
            clearInterval(interval);
        }
    }
    let start = function(){
        stop();
        data = init(_that);
        interval = setInterval(function(){
            if (!event(data, _that)){
                stop();
            }
        }, timeout);
    }
    return {
        start: start,
        stop: stop,
        setEvent: function(eventFunc){
            event = eventFunc;
        },
        setInit: function(initEvent){
            init = initEvent;
        }
    };
}